import axios from 'axios'
import {getToken} from '@/utils/auth'

const request = axios.create({
  withCredentials: false
})






request.interceptors.request.use(
  config => {

  if (getToken()) {
  config.headers['Authorization'] = getToken()
}

    return config
  },
  error => {
    console.log('error', error)
    return Promise.reject(new Error(error).message)
  }
)

request.interceptors.response.use(
  response => {
    return response.data
  },
  error => {
    return Promise.reject(new Error(error).message)
  }
)

export default request
